package com.example.baidu_map_plugin;


import android.util.Log;

import androidx.annotation.NonNull;

import com.example.baidu_map_plugin.location.BaiduLocationPlugin;
import com.example.baidu_map_plugin.mapview.FlutterNativeBaiDuMapPlugin;
import com.example.baidu_map_plugin.mapview.FlutterNativeMapViewFactory;


import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;


public class BaidumappluginOldPlugin implements MethodChannel.MethodCallHandler {
    private static final String TAG = BaidumappluginOldPlugin.class.getSimpleName();
    private static MethodChannel channel;
    private static BaiduLocationPlugin baiduLocationPlugin;

    /// 保留旧版本的兼容
    public static void registerWith(Registrar registrar) {
        channel = new MethodChannel(registrar.messenger(), "baidu_map_plugin");
        channel.setMethodCallHandler(new BaidumappluginOldPlugin());
        //百度地图
        FlutterNativeMapViewFactory.registerWith(registrar);
        //百度定位
        baiduLocationPlugin = new BaiduLocationPlugin(registrar, new BaidumappluginOldPlugin());
    }

    @Override
    public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
        Log.d(TAG, "onMethodCall():method=" + call.method + ",arguments=" + call.arguments);
        String method = call.method;
        switch (method) {
            case "getPlatformVersion":
                result.success("Android " + android.os.Build.VERSION.RELEASE);
                break;
            case "getLocation":
                if (baiduLocationPlugin != null) {
                    baiduLocationPlugin.onMethodCall(call, result);
                }
                break;
            default:
                result.notImplemented();
        }

    }

}
